
package Entity;

import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author JuanFelipe
 */
public class TableModelUser extends ListDataModel<User> implements SelectableDataModel<User>{
    
    public TableModelUser() {  
    }  
  
    public TableModelUser(List<User> user) {  
        super(user);  
    }  
      
    @Override
    public User getRowData(String rowKey) {  
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data  
          
        List<User> users = (List<User>) getWrappedData();  
          
        for(User user : users) {  
            if( user.getName().equals(rowKey) )  
                return user;  
        }  
          
        return null;  
    }  
  

    @Override
    public Object getRowKey(User user) {
        return user.getName();
    }
    
}

